import tracker from '../utils/tracker'


export function injectPv(){
  const connection = navigator.connection
  tracker.send({
    kind:'business',
    type:'pv',
    effectiveType:connection.effectiveType, // 网络环境
    rtt:connection.rtt,// 往返时间
    screen:`${window.screen.width}X${window.screen.height}` // 设备分辨率
  })
  // 停留时间
  const startTime = Date.now()
  window.addEventListener('unload',event=>{
    const stayTime = Date.now() - startTime
    tracker.send({
      kind:'business',
      type:"stayTime",
      stayTime
    })
  },false)
}